import java.io.*;
import java.util.*;

public class BreadthFirstSearch
{
    public static void main(String[] args) throws Exception
	{
		Scanner sc = new Scanner(new File("flip.in"));

		while(sc.hasNext())
		{
			// Read in all four rows as a single string
			String board = sc.nextLine();
			board += sc.nextLine();
			board += sc.nextLine();
			board += sc.nextLine();

			// Start off queue
			Queue<String> queue = new ArrayDeque<String>();
			queue.add(board);

			// Mark ourselves as the top
			HashMap<String, Boolean> visited = new HashMap<String, Boolean>();
			HashMap<String, String> solution = new HashMap<String, String>();
			solution.put(board, null);

			String curr = null;
			while(!queue.isEmpty())
			{
				curr = queue.remove();

				if(visited.containsKey(curr))
					continue;
				visited.put(curr, Boolean.TRUE);

				// Make each new board and place on queue
				for(int i = 0; i < curr.length(); i++)
				{
					StringBuilder sb = new StringBuilder(curr);

					// Self
					if(sb.charAt(i) == 'w')
						sb.replace(i, i + 1, "b");
					else
						sb.replace(i, i + 1, "w");

					// -4
					if(i > 3)
					{
						if(sb.charAt(i - 4) == 'w')
							sb.replace(i - 4, i - 3, "b");
						else
							sb.replace(i - 4, i - 3, "w");
					}

					// -1
					if(i % 4 != 0)
					{
						if(sb.charAt(i - 1) == 'w')
							sb.replace(i - 1, i, "b");
						else
							sb.replace(i - 1, i, "w");
					}

					// +1
					if((i + 1) % 4 != 0)
					{
						if(sb.charAt(i + 1) == 'w')
							sb.replace(i + 1, i + 2, "b");
						else
							sb.replace(i + 1, i + 2, "w");
					}

					// +4
					if(i < 12)
					{
						if(sb.charAt(i + 4) == 'w')
							sb.replace(i + 4, i + 5, "b");
						else
							sb.replace(i + 4, i + 5, "w");
					}

					String next = sb.toString();
					queue.add(next);

					if(!solution.containsKey(next))
						solution.put(next, curr);
				}

				// Check if solution
				boolean hasW = (curr.indexOf('w') != -1);
				boolean hasB = (curr.indexOf('b') != -1);
				if(hasW && !hasB)
					break;
				if(!hasW && hasB)
					break;
			}

			// Solution reached or nothing left to check?
			if(!queue.isEmpty())
			{
				// Trace back
				int steps = 0;
				String parent = solution.get(curr);
				while(parent != null)
				{
					parent = solution.get(parent);
					steps++;
				}

				System.out.println(steps);
			}
			else
				System.out.println("Impossible");
		}
    }
}
